import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from "path";
export default defineConfig(({mode}) => {
  //加载配置文件信息
  const env = loadEnv(mode,process.cwd());
  return {
    plugins: [vue()],
    resolve: {
      alias: {
        "@": path.resolve(__dirname, "./src")
      }
    },
    server: {
      // host:"0.0.0.0",
      port: env.VITE_APP_PORT,
      watch: {
        usePolling: true
      },
      // open: true,
      proxy: {
        '/api': {
          target: env.VITE_APP_SERVER_URL,
          changeOrigin: true,
          rewrite: (p) => p.replace(/^\/api/, '/api')
        }
      }
    }
  }

})
